﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TrainingWorkshop.DAL_EF.Translator
{
    public class CourseTranslator
    {
        //Transfer course to courseshows : from db to ui
        public static List<TrainingWorkshop.Models.CourseShows> TransfertoModelCourseList(List<Course> course)
        {
            List<TrainingWorkshop.Models.CourseShows> courseShowsList = new List<TrainingWorkshop.Models.CourseShows>();
            foreach (Course courseEntity in course)
            {
                //initiate the model.courseshows
                TrainingWorkshop.Models.Level level = new TrainingWorkshop.Models.Level();
                TrainingWorkshop.Models.Teacher teacher = new TrainingWorkshop.Models.Teacher();
                level.LevelId = courseEntity.LevelId;
                teacher.TeacherId = courseEntity.TeacherId;
                TrainingWorkshop.Models.CourseShows courseShows = new TrainingWorkshop.Models.CourseShows(level, teacher);

                courseShows.CourseId = courseEntity.CourseId;
                courseShows.CourseName = courseEntity.CourseName;
                courseShows.Level.LevelName = courseEntity.Level.LevelName;
                courseShows.Teacher.TeacherName = courseEntity.Teacher.TeacherName;
                courseShows.CourseStatus = courseEntity.CourseStatus;
                courseShowsList.Add(courseShows);
            }
            return courseShowsList;
        }
        //Transfer courseshows to course :from ui to db
        public static List<Course> TransfertoEntityCourseList(List<TrainingWorkshop.Models.CourseShows> courseShows)
        {
            List<Course> courseList = new List<Course>();
            foreach (TrainingWorkshop.Models.CourseShows courseShowsModel in courseShows)
            {
                Course course = new Course();
                course.CourseId = courseShowsModel.CourseId;
                course.CourseName = courseShowsModel.CourseName;
                course.LevelId = courseShowsModel.Level.LevelId;
                course.TeacherId = courseShowsModel.Teacher.TeacherId;
                course.CourseStatus = courseShowsModel.CourseStatus;
                courseList.Add(course);
            }
            return courseList;
        }
        public static Models.Course TransfertoModelCourse(Course course)
        {
            Models.Course courseModel = new Models.Course();
            courseModel.CourseId = course.CourseId;
            courseModel.CourseName = course.CourseName;
            courseModel.LevelId = course.LevelId;
            courseModel.TeacherId = course.TeacherId;
            courseModel.CourseStatus = course.CourseStatus;
            return courseModel;
        }
        public static Course TransfertoEntityCourse(Models.Course courseModel,Course courseEntity)
        {
            courseEntity.CourseName = courseModel.CourseName;
            courseEntity.LevelId = courseModel.LevelId;
            courseEntity.TeacherId = courseModel.TeacherId;
            courseEntity.CourseStatus = courseModel.CourseStatus;
            return courseEntity;
        }
    }
}
